﻿@using Pay.Token.Utils
@model PagedResult<product_dto>
@{
    var img_url = ViewBag.img_url;
    int userType = ViewBag.UserType;
    if (Model.rows.Count > 0) {
        foreach (var item in Model.rows) {
            <div class="item">
                <a href="@((item.activity_ex != null && item.activity_ex.is_sold_out == false
                && (item.activity_ex.begin_time <= DateTime.Now || (item.activity_ex.preheat_time != null && item.activity_ex.preheat_time <= DateTime.Now)) && item.activity_ex.end_time >= DateTime.Now)
                            ? "/DistributionMall/ProductDetail?productId=" + item.id :"javascript:void(0)")">
                    <div class="flex">
                        <div class="img">
                            <img src="@item.main_image_url">
                        </div>
                        <div class="flex-1">
                            <div class="tit fn-nowrap2 fn28">
                                @item.name
                            </div>
                            <div class="price">
                                <span class="col-red fn-left mr10">
                                    @if (item.price > 0) {
                                        <em class="fn22">￥</em><em class="fn32">@(item.price.ToString("0.##"))</em>
                                    }

                                    @if (item.price > 0 && item.activity_ex.activity_red_drill > 0) {
                                        <span>+</span>
                                    }

                                    @if (item.activity_ex.activity_red_drill > 0) {
                                        <em class="fn32">@(item.activity_ex.activity_red_drill.ToString("0.######"))</em> <em class="fn22">红钻</em>
                                    }
                                </span>
                                <div class="hidden">
                                    @if (item.activity_ex != null && item.activity_ex.activity_type == EActivityType.ProductTimeBuy) {
                                        <span class="fn22 col-gray">
                                            创客省<em class="fn24 col-red">@(((decimal)item.distribution_price * 0.5M).ToString("f2"))</em>
                                        </span>
                                    }
                                    <span class="fn-right">
                                        @if (item.activity_ex != null && item.activity_ex.begin_time <= DateTime.Now && item.activity_ex.end_time >= DateTime.Now) {
                                            if (item.activity_ex.is_sold_out == false) {
                                                <span class="ui-btn ui-btn-red">立即购买</span>
                                            } else {
                                                <span class="ui-btn ui-btn-cancel">已售罄</span>
                                            }
                                        } else if (item.activity_ex != null && item.activity_ex.end_time > DateTime.Now && item.activity_ex.begin_time > DateTime.Now) {
                                            <span class="ui-btn ui-btn-cancel">即将开始</span>

                                        } else {
                                            <span class="ui-btn ui-btn-cancel">已结束</span>
                                        }
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                </a>
            </div>
        }
    }
    <page total_pages="@Model.total_pages" rows="@Model.rows.Count()" total_result="@Model.total_result"></page>
}


